<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>屏幕共享</title>
</head>
<body>
  <button id="startShareButton">开始屏幕共享</button>

  <script>
    document.getElementById('startShareButton').addEventListener('click', function() {
      navigator.mediaDevices.getDisplayMedia({ video: true })
        .then(stream => {
          const videoElement = document.createElement('video');
          videoElement.srcObject = stream;
          videoElement.autoplay = true;
          document.body.appendChild(videoElement);
        })
        .catch(error => {
          console.error('无法启动屏幕共享:', error);
        });
    });
  </script>
</body>
</html>
